/**
 * 选择排序
 */

public class SelectSort {

    public static int[] list = {1, 2, 5, 33, 2, 9, 11, 89};

    public static void sort(int[] list) {
        for (int i = 0; i < list.length - 1; i++) {
            int index_min = i;
            for (int j = index_min + 1; j < list.length; j++) {
                if (list[j] < list[index_min]) {
                    index_min = j;
                }
            }

            if (i != index_min) {
                int tmp = list[i];
                list[i] = list[index_min];
                list[index_min] = tmp;
            }
        }

        for (int i : list) {
            System.out.println(i);
        }

    }


    public static void main(String[] args) {

        sort(list);
    }
}
